home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / nos042_s / ax25.h < prev    next >
C/C++ Source or Header  |  1994-09-16  |  8KB  |  245 lines

  1. /*
  2.     -----------------------------------------------------
  3.     ATARI Version by David Nash - dnash@chaos.demon.co.uk
  4.  
  5.    Hide definition of struct ax25_cb
  6.     -----------------------------------------------------
  7. */
  8.  
  9. #ifndef    _AX25_H
  10. #define    _AX25_H
  11.  
  12. #ifndef    _GLOBAL_H
  13. #include "global.h"
  14. #endif
  15.  
  16. #ifndef    _MBUF_H
  17. #include "mbuf.h"
  18. #endif
  19.  
  20. #ifndef    _IFACE_H
  21. #include "iface.h"
  22. #endif
  23.  
  24. #ifndef _SOCKADDR_H
  25. #include "sockaddr.h"
  26. #endif
  27.  
  28. #ifdef ATARI
  29. struct ax25_cb;    /* Hide tag for struct ax25_cb    */
  30. #endif
  31.  
  32. /* AX.25 datagram (address) sub-layer definitions */
  33.  
  34. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  35. #define    ALEN        6    /* Number of chars in callsign field */
  36. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  37. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  38.  
  39. #ifndef _LAPB_H
  40. #include "lapb.h"
  41. #endif
  42.  
  43. /* Bits within SSID field of AX.25 address */
  44. #define    SSID        0x1e    /* Sub station ID */
  45. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  46. #define    E        0x01    /* Address extension bit */
  47. #define    C        0x80    /* Command/response designation */
  48.  
  49. /* Our AX.25 address */
  50. extern char Mycall[AXALEN];
  51.  
  52. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  53. extern char Ax25multi[][AXALEN];
  54.  
  55. extern int Digipeat;
  56. extern int Ax25mbox;
  57.  
  58. /* Number of chars in interface field. The involved definition takes possible
  59.  * alignment requirements into account, since ax25_addr is of an odd size.
  60.  */
  61. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  62.  
  63. /* Socket address, AX.25 style */
  64. struct sockaddr_ax {
  65.     short sax_family;        /* 2 bytes */
  66.     char ax25_addr[AXALEN];
  67.     char iface[ILEN];        /* Interface name */
  68. };
  69.  
  70. /* Internal representation of an AX.25 header */
  71. struct ax25 {
  72.     char dest[AXALEN];        /* Destination address */
  73.     char source[AXALEN];        /* Source address */
  74.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  75.     int ndigis;            /* Number of digipeaters */
  76.     int nextdigi;            /* Index to next digi in chain */
  77.     int cmdrsp;            /* Command/response */
  78. };
  79.  
  80. /* C-bit stuff */
  81. #define    LAPB_UNKNOWN        0
  82. #define    LAPB_COMMAND        1
  83. #define    LAPB_RESPONSE        2
  84.  
  85. /* AX.25 routing table entry */
  86. struct ax_route {
  87.     struct ax_route *next;        /* Linked list pointer */
  88.     char target[AXALEN];
  89.     char digis[MAXDIGIS][AXALEN];
  90.     int ndigis;
  91.     char type;
  92. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  93. #define    AX_AUTO        2        /* Set by incoming packet */
  94. };
  95. #define NULLAXR    ((struct ax_route *)0)
  96.  
  97. extern struct ax_route *Ax_routes;
  98. extern struct ax_route Ax_default;
  99.  
  100. /* AX.25 Level 3 Protocol IDs (PIDs) */
  101. #define PID_X25        0x01    /* CCITT X.25 PLP */
  102. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  103. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  104. #define    PID_LQ        0xc4    /* Link quality protocol */
  105. #define    PID_APPLETALK    0xca    /* Appletalk */
  106. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  107. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  108. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  109. #define    PID_NETROM    0xcf    /* NET/ROM */
  110. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  111.  
  112. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  113. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  114.  
  115. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  116.  
  117. /* Link quality report packet header, internal format */
  118. struct lqhdr {
  119.     int16 version;        /* Version number of protocol */
  120. #define    LINKVERS    1
  121.     int32    ip_addr;    /* Sending station's IP address */
  122. };
  123. #define    LQHDR    6
  124. /* Link quality entry, internal format */
  125. struct lqentry {
  126.     char addr[AXALEN];    /* Address of heard station */
  127.     int32 count;        /* Count of packets heard from that station */
  128. };
  129. #define    LQENTRY    11
  130.  
  131. /* Link quality database record format
  132.  * Currently used only by AX.25 interfaces
  133.  */
  134. struct lq {
  135.     struct lq *next;
  136.     char addr[AXALEN];    /* Hardware address of station heard */
  137.     struct iface *iface;    /* Interface address was heard on */
  138.     int32 time;        /* Time station was last heard */
  139.     int32 currxcnt;    /* Current # of packets heard from this station */
  140.  
  141. #ifdef    notdef        /* Not yet implemented */
  142.     /* # of packets heard from this station as of his last update */
  143.     int32 lastrxcnt;
  144.  
  145.     /* # packets reported as transmitted by station as of his last update */
  146.     int32 lasttxcnt;
  147.  
  148.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  149.              * as of last update
  150.              */
  151.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  152.              * as of last update
  153.              */
  154. #endif
  155. };
  156. #define    NULLLQ    (struct lq *)0
  157.  
  158. extern struct lq *Lq;    /* Link quality record headers */
  159.  
  160. /* Structure used to keep track of monitored destination addresses */
  161. struct ld {
  162.     struct ld *next;    /* Linked list pointers */
  163.     char addr[AXALEN];/* Hardware address of destination overheard */
  164.     struct iface *iface;    /* Interface address was heard on */
  165.     int32 time;        /* Time station was last mentioned */
  166.     int32 currxcnt;    /* Current # of packets destined to this station */
  167. };
  168. #define    NULLLD    (struct ld *)0
  169.  
  170. extern struct ld *Ld;    /* Destination address record headers */
  171.  
  172. /* Linkage to network protocols atop ax25 */
  173. struct axlink {
  174.     int pid;
  175.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  176.      struct mbuf *,int));
  177. };
  178. extern struct axlink Axlink[];
  179.  
  180. /* Codes for the open_ax25 call */
  181. #define    AX_PASSIVE    0
  182. #define    AX_ACTIVE    1
  183. #define    AX_SERVER    2    /* Passive, clone on opening */
  184.  
  185. /* In ax25.c: */
  186. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  187. int ax_drop __ARGS((char *));
  188. struct ax_route *ax_lookup __ARGS((char *));
  189. void ax_recv __ARGS((struct iface *,struct mbuf *));
  190. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  191.     int del,int tput,int rel));
  192. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  193.     struct mbuf *data));
  194. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  195. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  196.     char *dest,struct mbuf *bp,int mcast));
  197.  
  198. /* In ax25cmd.c: */
  199. void st_ax25 __ARGS((struct ax25_cb *axp));
  200.  
  201. /* In axhdr.c: */
  202. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  203. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  204.  
  205. /* In axlink.c: */
  206. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  207. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  208. void logsrc __ARGS((struct iface *iface,char *addr));
  209. void logdest __ARGS((struct iface *iface,char *addr));
  210. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  211. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  212. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  213.  
  214. /* In ax25user.c: */
  215. #ifdef NEVER
  216. int ax25val __ARGS((struct ax25_cb *axp));
  217. int disc_ax25 __ARGS((struct ax25_cb *axp));
  218. int kick_ax25 __ARGS((struct ax25_cb *axp));
  219. #endif
  220. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  221.     int,int16,
  222.     void (*) __ARGS((struct ax25_cb *,int)),
  223.     void (*) __ARGS((struct ax25_cb *,int)),
  224.     void (*) __ARGS((struct ax25_cb *,int,int)),
  225.     int user));
  226. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  227. int reset_ax25 __ARGS((struct ax25_cb *axp));
  228. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  229.  
  230. /* In ax25subr.c: */
  231. int addreq __ARGS((char *a,char *b));
  232. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  233. void del_ax25 __ARGS((struct ax25_cb *axp));
  234. struct ax25_cb *find_ax25 __ARGS((char *));
  235. char *pax25 __ARGS((char *e,char *addr));
  236. int setcall __ARGS((char *out,char *call));
  237.  
  238. /* In socket.c: */
  239. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  240. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  241. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  242. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  243.  
  244. #endif  /* _AX25_H */
  245.